<template>
	<view class="plan-card">
		<view class="plan-card-header">
			<view class="haeder-left">
				<view class="time">
					{{ data.deliveryTime }}
				</view>
				<custom-tag cbackground="#B9EAFF" cborder="2rpx solid #00B2FF" text="宠物计划"></custom-tag>
			</view>
			<view class="header-right">
				<text class="unit">￥</text>
				<text class="number">{{ data.price || "--" }}</text>
			</view>
		</view>
		<view class="content">
			<view class="content-top">
				<view class="top-left">
					<u-image width="104rpx" height="104rpx" :src="data.petPlanPetInfos[0].photo.split(',')[0]"
						border-radius="16rpx"></u-image>
				</view>
				<view class="top-right">
					<view class="location-start">
						<span class="dot" />
						<span class="location">{{ data.deliveryAddress || "--" }}</span>
					</view>
					<view class="location-end">
						<span class="dot dotT" />
						<span class="location">{{ data.receivingAddress || "--" }}</span>
					</view>
				</view>
			</view>
			<view class="content-bottom">
				<view class="bottom-left">
					<u-image width="26rpx" height="32rpx" src="/static/index/location2.png"></u-image>
					<span class="number">{{ data.distance.substr(0,4)?data.distance.substr(0,4) : "--" }}km</span>
				</view>
				<view class="bottom-right">
					<u-image width="32rpx" height="32rpx" src="/static/index/animal.png"></u-image>
					<span class="number">{{ petPlanPetInfosNum }}只</span>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import customTag from "../custom-tag.vue";
	export default {
		props: {
			data: {
				type: Object,
				default: {
					delivery: "",
					deliveryAddress: "",
					deliveryPhone: "",
					deliveryTime: "",
					lat: 0,
					lng: 0,
					petPlanPetInfos: [],
					price: "",
					publisherId: "",
					remark: "",
					receivingAddress: "",
					recipient: "",
					recipientPhone: "",
					distance: 0,
				},
			},
		},

		data() {
			return {
				petPlanPetInfosNum: 2,
			};
		},

		mounted() {
			this.petPlanPetInfosNum = this.data.petPlanPetInfos.length;
		},
		components: {
			customTag,
		},
	};
</script>

<style lang="scss" scoped>
	.plan-card {
		display: flex;
		flex-direction: column;
		background: #ffffff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 0 24rpx;

		.plan-card-header {
			display: flex;
			justify-content: space-between;
			padding: 16rpx 0;
			border-bottom: 2rpx solid #f3f3f3;

			.haeder-left {
				display: flex;
				align-items: center;

				.time {
					font-family: PingFang SC, PingFang SC;
					font-weight: bold;
					font-size: 28rpx;
					color: #000000;
					text-align: left;
					font-style: normal;
					text-transform: none;
				}
			}

			.header-right {
				font-weight: bold;
				color: #ff7676;
				text-align: left;
				font-style: normal;

				.unit {
					font-size: 24rpx;
				}

				.number {
					font-size: 40rpx;
				}
			}
		}

		.content {
			padding: 16rpx 0;

			.content-top {
				display: flex;

				.top-left {
					width: 104rpx;
					height: 104rpx;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;
				}

				.top-right {
					flex: 1;
					display: flex;
					flex-direction: column;
					overflow: hidden;
					white-space: nowrap;
					text-overflow: ellipsis;

					.location-start,
					.location-end {
						flex: 1;
						display: flex;
						align-items: center;
						padding-left: 16rpx;

						.dot {
							display: block;
							width: 16rpx;
							height: 16rpx;
							border-radius: 50%;
							border: 1px solid #999999;
							margin-right: 8rpx;
						}

						.dotT {
							background: #fcd610;
							border: 1px solid #fcd610;
						}

						.location {
							font-weight: 500;
							font-size: 32rpx;
							color: #333333;
							overflow: hidden;
							white-space: nowrap;
							text-overflow: ellipsis;
						}
					}
				}
			}

			.content-bottom {
				display: flex;
				justify-content: space-between;
				padding: 8rpx 0;

				.bottom-right,
				.bottom-left {
					display: flex;
					align-items: center;

					.number {
						font-weight: 500;
						font-size: 12px;
						color: #999999;
						display: block;
					}
				}
			}
		}
	}
</style>